# - Try to find INTEL_EXT_PT_CPU
#
# The following are set after configuration is done:
#  INTEL_EXT_PT_CPU_FOUND          : set to true if Intel(R) Extension for PyTorch* is found.
#  TORCH_CXX_FLAGS      : Append cxx flags of Intel(R) Extension for PyTorch* to TORCH_CXX_FLAGS
#  TORCH_LIBRARIES      : Append libraries of Intel(R) Extension for PyTorch* to TORCH_CXX_FLAGS
#

IF (NOT INTEL_EXT_PT_CPU_FOUND)

FIND_PACKAGE(Torch REQUIRED)
FIND_LIBRARY(INTEL_EXT_PT_CPU_LIBRARY libintel-ext-pt-cpu.so PATHS "${TORCH_INSTALL_PREFIX}/lib")
if(INTEL_EXT_PT_CPU_LIBRARY)
  add_library(intel_ext_pt_cpu_library INTERFACE IMPORTED)
  set_target_properties(intel_ext_pt_cpu_library PROPERTIES
	  INTERFACE_LINK_LIBRARIES "-Wl,--no-as-needed,\"${INTEL_EXT_PT_CPU_LIBRARY}\""
  )

  LIST(APPEND TORCH_LIBRARIES intel_ext_pt_cpu_library)

  SET(INTEL_EXT_PT_CPU_FOUND TRUE)
  MESSAGE(STATUS "Found INTEL_EXT_PT_CPU: TRUE")
else()
  MESSAGE(STATUS "Found INTEL_EXT_PT_CPU: FALSE")
endif()

ENDIF(NOT INTEL_EXT_PT_CPU_FOUND)
